'use strict';

const mongoose = require('mongoose'),
      MerchantInfoSchema = require('./merchantInfo.model.js');

const AdvertModel = new mongoose.Schema({
    food: String,
    price: String,
    picUrl: String,
    merchant: MerchantInfoSchema,
    status: String,
    applyTime: Date,
    reviewTime: Date
},{
    collection: 'advert'
});

AdvertModel.pre('save', function (next) {
    var doc = this;
    doc.applyTime = new Date();
    doc.status = '0';
    console.log("pre advert save hook!!!")
    console.log(doc)
    next();
});

mongoose.model('advert', AdvertModel);